package libs.yzx.zaza;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;
import android.support.annotation.Nullable;
import android.widget.Toast;

/**
 * Created by Administrator on 2016/7/29.
 */
public class MyBindService extends Service {

    private TestBinder tb;

    public class TestBinder extends Binder {
        public String get() {
            return count + "__";
        }

        @Override
        protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
            return super.onTransact(code, data, reply, flags);
        }
    }


    private int count;


    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return tb = new TestBinder();
    }

    @Override
    public boolean onUnbind(Intent intent) {
        Toast.makeText(MyBindService.this, "unbind", Toast.LENGTH_SHORT).show();
        return super.onUnbind(intent);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Toast.makeText(MyBindService.this, "destroy", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onRebind(Intent intent) {
        super.onRebind(intent);
        Toast.makeText(MyBindService.this, "rebind", Toast.LENGTH_SHORT).show();
    }


}
